package com.bw.ods;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.ververica.cdc.connectors.mysql.MySQLSource;
import com.alibaba.ververica.cdc.debezium.DebeziumSourceFunction;
import com.bw.fun.DimSinkFunc;
import com.bw.fun.MyJsonSchema;
import com.bw.utils.MyKafkaUtil;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.ProcessFunction;
import org.apache.flink.util.Collector;
import org.apache.flink.util.OutputTag;

public class XT0 {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(1);


        DebeziumSourceFunction<String> source = MySQLSource.<String>builder()
                .hostname("hadoop120")
                .port(3306)
                .databaseList("gmall") // set captured database
                //.tableList("yourDatabaseName.yourTableName") // set captured table
                .username("root")
                .password("123456")
                .deserializer(new MyJsonSchema()) // converts SourceRecord to JSON String
                .build();

        DataStreamSource<String> stream = env.addSource(source);
        stream.addSink(MyKafkaUtil.getKafkaProducer("topic-db-yk2"));


        env.execute();
    }
}
